package com.jumi.microservice.controller.comment.admin;

import com.jumi.microservice.common.base.BaseController;
import com.jumi.microservice.common.base.dto.ResponseResult;
import com.jumi.microservice.common.page.TableDataInfo;
import com.jumi.microservice.dto.comment.admin.CommentHideRequest;
import com.jumi.microservice.dto.comment.admin.CommentListRequest;
import com.jumi.microservice.dto.comment.admin.CommentListResponse;
import com.jumi.microservice.dto.comment.admin.CommentReplyRequest;
import com.jumi.microservice.service.comment.AdminCommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author Scw
 * @Date 2020-08-04 17:54
 */
@Api(tags = {"后台商品评论相关接口"})
@RestController
@RequestMapping("/admincomment")
public class AdminCommentController extends BaseController {
    @Resource
    private AdminCommentService adminCommentService;

    @GetMapping("/commentAdminList")
    @ApiOperation("评论列表")
    TableDataInfo<CommentListResponse> commentAdminList(CommentListRequest commentListRequest) {
        //获取当前用户Id
        //commentListRequest.setUid(getUid());//后台获取用户id
        //commentListRequest.setUid(10119L);
        return adminCommentService.commentsAdminList(commentListRequest);
    }

    /**
     * * 是否隐藏
     * @param :                  0:否 1是
     * @param commentHideRequest
     * @return
     */
    @PutMapping("/editHide")
    @ApiOperation("是否隐藏")
    public ResponseResult<Boolean> editHide(CommentHideRequest commentHideRequest) {
        //commentHideRequest.setUid(10119L);
        //commentHideRequest.setUid(getUid());
        ResponseResult<Boolean> result = new ResponseResult<>();
        result.setData(adminCommentService.editHide(commentHideRequest));
        return result;
    }

    @PutMapping("/editReply")
    @ApiOperation("回复内容")
    public ResponseResult<Boolean> editReply(CommentReplyRequest commentReplyRequest) {
        //commentReplyRequest.setUid(getApiUserId().longValue());
        //commentReplyRequest.setUid(10119L);
        /* commentReplyRequest.setUid(getUid());*/
        ResponseResult<Boolean> result = new ResponseResult<>();
        result.setData(adminCommentService.editReply(commentReplyRequest));
        return result;
    }
}
